
var phoneWorry = false;
var pwdWorry = false;
var pwd2Worry = false;

/**
 * 手机号判定 ajax
 */
function phonePanding(){
	var phoneNumber = $("#phone").val();
	if(phoneNumber.match(/^[1][358][0-9]{9}$/)){
		phonePanding1(phoneNumber);
	}else{
		var errdiv = $("#phoneMessage");
		errdiv.html("<font style='color:#F00'>请输入正确的手机号</font>");
		phoneWorry = true;
	}
}
function phonePanding1(phoneNumber){
	$.ajax({
		type:"GET",
		data:"phonenumber="+phoneNumber,
		url:"../phone",
		dataType:"text",
		error:function(err){
			alert("错误");
		},
		success:ajaxSendCallBack
	})
}
function ajaxSendCallBack(data){
	$("#phoneMessage").html(data);
	phoneWorry = false;
}

/*
 * pwd判断
 */
function pwdPanding(){
	var $pwd = $("#pwd").val();
	if($pwd.length<6){
		$("#mmMessage").html("<font style='color:#F00'>密码长度太短</font>");
		pwdWorry=true;
	}else if($pwd.length>18){
		$("#mmMessage").html("<font style='color:#F00'>密码长度太长</font>");
		pwdWorry=true;
	}else{
		$("#mmMessage").html("<font style='color:#0F0'>请牢记此密码</font>");
		pwdWorry=false;
	}
}
/*
 * pwd2判断
 */
function pwdPanding2(){
	var $pwd=$("#pwd").val();
	var $pwd2 = $("#pwd2").val();
	
	if($pwd==$pwd2){
		$("#mm2Message").html("<font style='color:#F00'>确认密码匹配</font>");
		pwd2Worry=false;
	}else{
		$("#mm2Message").html("<font style='color:#F00'>两次密码不匹配</font>");
		pwd2Worry=true;
	}
}

/*
 * submit
 */
$(function(){
	$("#sub").bind("click",function(e){
		var $inputTexts = $(":text,:password");
		$inputTexts.each(function(){
			if($(this).val()==""){
				e.preventDefault();
				$("#registeMessage").html("<font style='color:#F00'>请确认表单填写正确</font>");
			}
			if(phoneWorry||pwdWorry||pwd2Worry){
				e.preventDefault();
				$("#registeMessage").html("<font style='color:#F00'>请确认表单填写正确</font>");
			}
		})
	})
})


